package com.homelock.common.enumeration;

/**
 * 开门记录 报警记录 触发类型
 */
public enum TriggerTypeEnum {
    /**
     * MESSAGE:1 普通开门记录 （messagetype+tigggertype)
     * 1：远程开锁消息
     * 2：蓝牙开锁消息
     * 3：机械钥匙开锁消息
     * 4：刷卡开锁消息
     * 5：指纹开锁消息
     * 6：密码开锁消息
     */
    /**
     * 报警类型 ALARM 2
     * 报警类型（请使用位操作来判断当前的报警状态，如果为0则表示未触发报警）
     * 0x01：翘锁报警  1
     * 0x02：假锁报警  10
     * 0x04：电池欠压报警  100
     * 0x08：禁试报警   1000
     * 0x10：水浸报警   10000
     * 0x20：高温报警    100000
     */
    UNDEFINED_TIGGER(-1,""), // 不匹配的Tigger
    IGNORE_TIGGER(0,""),  // 需要被忽略的TIGGER
    REMOTE_OPEN(11,"远程开锁"),
    BLUETOOH_OPEN(12,"蓝牙开锁"),
    KEY_OPEN(13,"机械钥匙开锁"),
    CARD_OPEN(14,"刷卡开锁"),
    FINGER_OPEN(15,"指纹开锁"),
    PWD_OPEN(16,"密码开锁"),
    TEMP_PWD_OPEN(17,"临时密码开锁"),

    PICK_ALARM(21,"撬锁报警",0),
    SPURIOUS_ALAMR(22,"假锁报警",1),
    BATTERY_ALAMR(24,"电池欠压报警",2),
    FINGER_ALARM(25,"指纹报警"),
    PWD_ALARM(26,"密码报警"),
    RETRY_FORBIDDEN_ALARM(28,"禁试报警",3),
    WATEROUT_ALARM(216,"水浸报警",4),
    HIGH_TEMPERATURE_ALARM(232,"高温报警",5);


    private int code;
    private String name;
    private int position = -1;
    private TriggerTypeEnum(int code,String name){
        this.code = code;
        this.name = name;
    }

    private TriggerTypeEnum(int code,String name,int position){
        this.code = code;
        this.name = name;
        this.position = position;
    }

    public static TriggerTypeEnum val(int operate) {
        for(TriggerTypeEnum s : values()) {    //values()方法返回enum实例的数组
            if(operate == s.getCode())
                return s;
        }
        return UNDEFINED_TIGGER;
    }

    public static TriggerTypeEnum position(int index) {
        for(TriggerTypeEnum s : values()) {    //values()方法返回enum实例的数组
            if(index == s.getPosition())
                return s;
        }
        return UNDEFINED_TIGGER;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }
}
